//
//  HomeRecommendGoodsCardView.swift
//  HomeRecommendGoodsCardView
//
//  Created by Ben on 2021/8/20.
//

import SwiftUI
import SDWebImageSwiftUI

struct HomeRecommendGoodsCardView: View {
    
    var goodsCardModel: GoodsCardModel
    
    var body: some View {
        
        // 切换分类获取商品信息功能完成，感谢您的观看，本期视频到此结束，下期视频将给该商品列表添加下拉刷新及上拉加载更多功能，敬请期待。
        VStack(alignment: .leading, spacing: 10) {
            WebImage(url: URL(string: "https://" + (goodsCardModel.goodsInfo?.url ?? "")))
                .resizable()
                .aspectRatio(contentMode: .fit)
                .cornerRadius(10)
            
            Text(goodsCardModel.goodsInfo?.name ?? "")
                .font(.system(size: 14, weight: .semibold))
            
            HStack {
                (
                    Text("¥")
                        .font(.system(size: 12))
                    +
                    Text(goodsCardModel.goodsPriceStr)
                        .font(.system(size: 18))
                )
                    .foregroundColor(.red)
                    .fontWeight(.semibold)
                    

                Spacer()
                
                Text("\(goodsCardModel.goodsInfo?.want_buy_count ?? 0)人想要")
                    .font(.system(size: 12))
                    .foregroundColor(Color.black.opacity(0.4))
            }
            
            HStack {
                WebImage(url: URL(string: goodsCardModel.seller?.avatar ?? ""))
                    .resizable()
                    .aspectRatio(contentMode: .fit)
                    .frame(width: 30, height: 30)
                    .clipShape(Circle())
                
                Text(goodsCardModel.seller?.nick_name ?? "")
                    .font(.system(size: 12))
                    .foregroundColor(Color.black.opacity(0.4))
                    .lineLimit(1)

                Spacer()
                
                Image("goodscard_seller_zhima_good")
                    .resizable()
                    .aspectRatio(contentMode: .fit)
                    .frame(width: 80)
            }
        }
    }
}
